#ifndef STUN_PROTOCOL_PARSER_H_
#define STUN_PROTOCOL_PARSER_H_

#include <cstdint>
#include <memory>

class StunMsg;
class StunProtocolParser
{
public:
    enum ParserStunStatus
    {
        INIT,
        NEED_DATA,
        FINISH,
        BAD,
    };

public:
    StunProtocolParser();
    int                      ParserStunMsg(const uint8_t * data, int data_length, int & use_length);
    int                      ComposeStunMsg(uint8_t * data, int data_length) const;
    void                     ResetStunMsg();
    std::shared_ptr<StunMsg> StunMsgPtr();

private:
    int ParserStunMsgHeader(const uint8_t * data, int data_length, int & use_length);
    int ParserStunMsgAttr(const uint8_t * data, int data_length, int & use_length) const;
    static int ComposeStunMsgHeader(uint8_t * data);
    int ComposeStunMsgAttr(uint8_t * data) const;

private:
    std::shared_ptr<StunMsg> m_stun_msg;
};

#endif
